package com.mazaiting.classfile.constant.info;

import com.mazaiting.classfile.ClassReader;
import com.mazaiting.classfile.constant.ConstantPool;
import com.mazaiting.util.ByteUtil;
import lombok.Getter;

/**
 * 单精度常量信息
 * 4字节存储IEEE754单精度浮点数 常量
 * @author mazaiting
 * @since 2021/8/12
 */
@Getter
public class ConstantFloatInfo extends ConstantInfo {
    /**
     * 数值
     */
    private float value;

    public ConstantFloatInfo(ConstantPool pool) {
        super(pool);
    }

    @Override
    public void readInfo(ClassReader reader) {
        this.value = ByteUtil.byteToFloat(reader.readU4());
    }

    @Override
    public String toString() {
        return "ConstantFloatInfo{" +
                "value=" + value +
                '}';
    }
}


















